home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Storm
/
Scene Storm - Volume 1.iso
/
coding
/
c
/
fullbench
/
fullbench.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-12-16
|
5KB
|
171 lines
#include <string.h>
#include <stdlib.h>
#include <proto/intuition.h>
#include <proto/exec.h>
#include <exec/ports.h>
#include <dos/dos.h>
#include <proto/dos.h>
#include <dos/notify.h>
#include <exec/memory.h>
static UBYTE *version_string = "$VER: FullBench 1.21 (2.10.95)";
BOOL InitFull(struct Window **MyWindow, BOOL);
__chip UWORD knapp[] =
{
0x0000,0x0000,0x0000,0x0200,0x0FFC,0x0200,0x0800,0x0200,
0x0800,0x0200,0x0800,0x2200,0x0800,0x2200,0x0800,0x2200,
0x0000,0x2200,0x0000,0x2200,0x007F,0xE200,0x0000,0x0200,
0xFFFF,0xFE00,
0xFFFF,0xFE00,0x8000,0x0000,0x8000,0x0000,0x8002,0x0000,
0x80FF,0xC000,0x8080,0x0000,0x8080,0x0000,0x8080,0x0000,
0x8780,0x0000,0x8080,0x0000,0x8000,0x0000,0x8000,0x0000,
0x0000,0x0000,
};
__chip UWORD knapp2[] =
{
0xFFFF,0xFE00,0x8000,0x0000,0x8000,0x0000,0x8002,0x0000,
0x8002,0x0000,0x8002,0x2000,0x8002,0x2000,0x8002,0x2000,
0x87FE,0x2000,0x8000,0x2000,0x807F,0xE000,0x8000,0x0000,
0x0000,0x0000,
0x0000,0x0000,0x0000,0x0200,0x0FFC,0x0200,0x0800,0x0200,
0x08FD,0xC200,0x0880,0x0200,0x0880,0x0200,0x0880,0x0200,
0x0000,0x0200,0x0080,0x0200,0x0000,0x0200,0x0000,0x0200,
0xFFFF,0xFE00,
};
struct Image MyButt =
{
0, 0, /* Upper left corner */
23, 13, 2, /* Width, Height, Depth */
knapp, /* Image data */
0x03, 0x00, /* PlanePick, PlaneOnOff */
NULL, /* Next image */
};
struct Image MyButt2 =
{
0, 0, /* Upper left corner */
23, 13, 2, /* Width, Height, Depth */
knapp2, /* Image data */
0x03, 0x00, /* PlanePick, PlaneOnOff */
NULL, /* Next image */
};
struct EasyStruct err = {
sizeof(struct EasyStruct), 0,
"FullBench 1.21",
"Can't find Worbench screen\n or WB is not backdrop",
"Continue",
};
struct Gadget MyDepthGad = {
NULL, 0, 0, 24, 13,
GFLG_GADGIMAGE | GFLG_GADGHIMAGE,
GACT_RELVERIFY,
GTYP_SDEPTH,
&MyButt, &MyButt2, NULL, NULL, NULL
};
void __stdargs __main(char *unused)
{
struct Window *MyWindow=NULL;
struct Task *OldTask;
int signal, signr=-1;
struct NotifyRequest *MyNotify;
BOOL notify = FALSE;
STRPTR oldname = FindTask(NULL)->tc_Node.ln_Name;
Forbid();
if(OldTask = FindTask("task_FullBench"))
{
Signal(OldTask, SIGBREAKF_CTRL_C);
Permit();
exit(0);
}
Permit();
FindTask(NULL)->tc_Node.ln_Name = "task_FullBench";
if((MyNotify = AllocMem(sizeof(struct NotifyRequest), MEMF_CLEAR))
&& (signr = AllocSignal(-1L)) != -1){
MyNotify->nr_Name = "Env:sys/screenmode.prefs";
MyNotify->nr_Flags = NRF_SEND_SIGNAL;
MyNotify->nr_stuff.nr_Signal.nr_Task = (struct Task *) FindTask(NULL);
MyNotify->nr_stuff.nr_Signal.nr_SignalNum = signr;
StartNotify(MyNotify);
notify = TRUE;
}
if(!InitFull(&MyWindow, TRUE)) goto quit;
for(;;){
signal = Wait(SIGBREAKF_CTRL_C | (1L << signr));
if(!(signal & (1L << signr))) break;
if(MyWindow){
CloseWindow(MyWindow);
MyWindow = NULL;
}
Delay(250);
if(!InitFull(&MyWindow, TRUE)) goto quit;
}
InitFull(&MyWindow, FALSE);
quit:
FindTask(NULL)->tc_Node.ln_Name = oldname;
if(notify) EndNotify(MyNotify);
if(signr != -1) FreeSignal(signr);
if(MyNotify) FreeMem(MyNotify, sizeof(struct NotifyRequest));
if(MyWindow) CloseWindow(MyWindow);
exit (0);
}
BOOL InitFull(struct Window **MyWindow, BOOL on)
{
struct Window *WBWin;
BOOL error = FALSE;
struct Screen *WBScreen;
if((!(WBScreen = (struct Screen *)LockPubScreen("Workbench")))){
EasyRequestArgs(NULL, &err, NULL, NULL);
return(FALSE);
}
Forbid();
for(WBWin = WBScreen->FirstWindow; WBWin
&& (strncmp(WBWin->ScreenTitle,"Amiga Workbench",15)
&& strncmp(WBWin->ScreenTitle,"Attempting to load program",25)
&& strncmp(WBWin->ScreenTitle,"Copyright © 1985-199",20)
&& strncmp(WBWin->ScreenTitle,"Cannot Quit yet",15)
|| WBWin->Title!=NULL); WBWin = WBWin->NextWindow);
Permit();
if (!WBWin) {
EasyRequestArgs(NULL, &err, NULL, NULL);
goto quit;
}
if(on)
ChangeWindowBox(WBWin,WBWin->LeftEdge,0, WBWin->Width,WBScreen->Height);
else
ChangeWindowBox(WBWin,WBWin->LeftEdge,(WBScreen->BarHeight+1),
WBWin->Width,WBScreen->Height-(WBScreen->BarHeight+1));
ShowTitle(WBScreen, !on); /* Vises kun ved full workbench */
if(on){
if(!((*MyWindow) = OpenWindowTags(NULL, WA_Top, 0,
WA_Left, 32000,
WA_Height, MyButt.Height,
WA_Width, MyButt.Width,
WA_AutoAdjust, TRUE,
WA_Gadgets, &MyDepthGad,
WA_Flags, WFLG_BORDERLESS|WFLG_BACKDROP,
TAG_END)))
goto quit;
error=TRUE;
}
quit:
UnlockPubScreen(NULL, WBScreen);
return(error);
}